<?php
namespace App\Models\Lession;


use App\Models\Lession\Course;
use App\Models\Lession\Scolumn;
use App\Models\Lession\Lessource;
class Lession extends \App\Libs\Base\BaseModel
{
    protected $__TABLE__ = 't_jia_lessions';


	public function beforeValidation()
	{
	 self::skipValidation(['play_num','flower_num','comment_num','isshow'] , $this );
	}
	public function getCourseData(){
	    switch ($this->type){
            case '1':
                $table = 'App\Models\Lession\Course';
                break;
            case '2':
                $table = 'App\Models\Lession\Scolumn';
                break;
        }
        return $table::findOne([
            'conditions' => 'id=?1',
            'bind' => [1=>$this->coustar_id]
        ]);

    }

    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->hasOne('id','App\Models\Lession\Lessource','lession_id',['alias'=>'lesource']);

    }


}
